<template>
  <!--条件管理-->
    <basic-container>
        <div>
            <m-s-search @searchClick="v=>{queryForm=v,page.currentPage=1,getList()}" :list="ConditionOption.column"></m-s-search>
        </div>
        <avue-crud :option="ConditionOption"
                   :data="data"
                   :table-loading="loading"
                   @selection-change="v=>selection=v"
                   @current-change="currentChange"
                   @size-change="sizeChange"
                   ref="crud"
                   :page.sync="page">
            <template slot="menuLeft" slot-scope="{size}">
                <el-button :size="size" type="primary"
                           @click="addToTabsList('条件',{oid:-1},'conditionTemp','open')">
                    新增
                </el-button>
                <el-button :size="size" :disabled="selection.length!==1" @click="remove(selection)">删除</el-button>
                <el-button :size="size" :disabled="selection.length===0"
                           @click="start_stop(selection,'start')">
                    启用
                </el-button>
                <el-button :size="size" :disabled="selection.length===0"
                           @click="start_stop(selection,'stop')">
                    停用
                </el-button>
            </template>

            <template slot="nameCn" slot-scope="{row}">
                <span class="column-btn"
                      @click="addToTabsList(row.nameCn+'条件',row,'conditionTemp','view')">
                    {{ row.nameCn }}
                  </span>
            </template>

            <template slot="menu" slot-scope="{row}">
                <el-button type="text"
                           @click="addToTabsList(row.nameCn+'条件',row,'conditionTemp','view')">
                    查看详情
                </el-button>
                <el-button type="text"
                           @click="addToTabsList(row.nameCn+'条件',row,'conditionTemp','edit')">
                    修改
                </el-button>
                <el-button type="text" :disabled="row.checkState === 1" @click="checkIn(row)">检入</el-button>
                <el-button type="text" :disabled="row.checkState === 1" @click="unCheckOut(row)">撤销检出</el-button>
            </template>
        </avue-crud>

        <ms-drawer @refresh="getList()" ref="md" :visible.sync="visible" :tab-list.sync="tabsList"></ms-drawer>
    </basic-container>
</template>
<script>
import MSSearch from "@/DMDComponents/MSSearch.vue";
import commonJs from "@/util/commonJs";

export default {
    name: "Condition",
    components: {MSSearch},
    inject: ["ConditionOption"],
    mixins: [commonJs],
}
</script>
<style scoped>

</style>
